#include "gameobject.h"
#include "movestate.h"
#include "attackstate.h"

void MoveState::enter(GameObject *gameObject)
{
    gameObject->setColor(Qt::green); // 进入移动状态,设置对象为绿色
    gameObject->setTarget(); // 恢复移动
}

void MoveState::handle(GameObject *gameObject)
{
    (void)gameObject;

    // 如果有敌人在攻击范围, 那么切换状态为攻击状态
    if (gameObject->isEnemyInRange()){
        gameObject->setState(new AttackState());
        return;
    }
    gameObject->setTarget();
}

void MoveState::exit(GameObject *)
{

}
